package com.gegewa.topic.algorithm;

public class BubbleSort {

    public static void main(String[] args) {
        int[] data = new int[] {5, 6, 2, 0, 5};
        sort(data);
        for (int i = 0, size = data.length; i < size; i++) {
            System.out.println(data[i]);
        }
    }

    public static void sort(int[] data) {
        for (int i = 0, iCount = data.length - 1; i < iCount; i++) {
            for (int j = i + 1, jCount = data.length; j < jCount; j++) {
                if (data[i] > data[j]) {
                    int temp = data[i];
                    data[i] = data[j];
                    data[j] = temp;
                }
            }
        }
    }

}
